using System;
using System.Collections.Generic;
using System.Web;

namespace OpenWaves.ActivityFeed.Web.Handler
{
    public class RestModule : IRestModule
    {
        private readonly Dictionary<IActionSelector, Func<HttpRequestBase, IDictionary<string, string>, IActionResult>> actions = new Dictionary<IActionSelector, Func<HttpRequestBase, IDictionary<string, string>, IActionResult>>();
        public IDictionary<IActionSelector, Func<HttpRequestBase, IDictionary<string, string>, IActionResult>> Actions
        {
            get { return this.actions; }
        }

        protected void Get(string path, Func<HttpRequestBase, IDictionary<string, string>, IActionResult> action)
        {
            this.actions.Add(new ActionSelector("GET", UrlPath.Parse(path)), action);
        }

        protected void Post(string path, Func<HttpRequestBase, IDictionary<string, string>, IActionResult> action)
        {
            this.actions.Add(new ActionSelector("POST", UrlPath.Parse(path)), action);
        }

        protected void Delete(string path, Func<HttpRequestBase, IDictionary<string, string>, IActionResult> action)
        {
            this.actions.Add(new ActionSelector("DELETE", UrlPath.Parse(path)), action);
        }
    }
}